<?php defined('IN_IA') or exit('Access Denied');?><?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('common/header', TEMPLATE_INCLUDEPATH)) : (include template('common/header', TEMPLATE_INCLUDEPATH));?>

<ul class="nav nav-tabs">
	<?php  if($cattype == 1) { ?>
		<li <?php  if($operation == 'display') { ?>class="active"<?php  } ?>><a href="<?php  echo $this->createWebUrl('postercate',array('op' =>'display','cattype'=>1))?>">海报分类管理</a></li>
		<li <?php  if(empty($othercat['id']) && $operation == 'post') { ?>class="active"<?php  } ?>><a href="<?php  echo $this->createWebUrl('postercate',array('op' =>'post','cattype'=>1))?>">添加海报分类</a></li>
		<?php  if(!empty($othercat['id']) &&  $operation == 'post') { ?><li class="active"><a href="###">编辑海报分类</a></li><?php  } ?>
	<?php  } ?>
</ul>

<?php  if($operation == 'display') { ?>
<div class="main panel panel-default">
	<div class="panel-body table-responsive">
		<form action="" method="post">
		<table class="table table-hover">
			<thead class="navbar-inner">
				<tr>
					<th style="width:8%;">排序</th>
					<th style="width:30%;">分类名称</th>
					<th>所属类型</th>
					<th style="width:6%;">状态</th>
					<th style="text-align:right;">操作</th>
				</tr>
			</thead>
			<tbody>
				<?php  if(is_array($list)) { foreach($list as $othercat) { ?>
				<tr>
					<td><input class="form-control" name="displayorder[<?php  echo $othercat['id'];?>]" value="<?php  echo $othercat['displayorder'];?>" type="text"></td>
					<td>
						<span class="label label-success"><?php  echo $othercat['catename'];?></span>
					</td>
					<td>
						<span class="label label-info">
							<?php  if($othercat['shop_id'] > 0) { ?>默认分类<?php  } else { ?>自定义分类<?php  } ?>
						</span>
					</td>
					<td>
						<?php  if($othercat['enabled'] == 1) { ?>
							<span class="label label-success">已启用</span>
						<?php  } else { ?>
							<span class="label label-danger">未启用</span>
						<?php  } ?>
					</td>
					<td style="text-align:right;">
						<a href="<?php  echo $this->createWebUrl('postercate', array('op' => 'post', 'id' => $othercat['id'],'cattype'=>$cattype))?>" class="btn btn-default btn-sm" title="修改"><i class="fa fa-edit"></i></a>
						<a href="<?php  echo $this->createWebUrl('postercate', array('op' => 'delete', 'id' => $othercat['id']))?>"class="btn btn-default btn-sm" onclick="return confirm('此操作不可恢复，确认删除？');return false;" data-toggle="tooltip" data-placement="top" title="删除"><i class="fa fa-times"></i></a>
					</td>
				</tr>
				    <?php  if(is_array($othercat['erji'])) { foreach($othercat['erji'] as $row) { ?>
					<tr>
						<td><input class="form-control" name="displayorder[<?php  echo $row['id'];?>]" value="<?php  echo $row['displayorder'];?>" type="text"></td>
						<td></td>
						<td>
							<div style="padding-left:50px;height:30px;line-height:30px;background:url('./resource/images/bg_repno.gif') no-repeat -245px -545px;"><?php  if($row['thumb']) { ?><img src="<?php  echo tomedia($row['thumb']);?>" style="margin-right:5px;" width="30" height="30" /><?php  } ?><span class="label label-success"><?php  echo $row['catename'];?></span></div>
						</td>
						<td>
							<span class="label label-info">
								<?php  if($othercat['shop_id'] > 0) { ?>默认分类<?php  } else { ?>自定义分类<?php  } ?>
							</span>
						</td>
						<td>
							<?php  if($row['enabled'] == 1) { ?>
								<span class="label label-success">已启用</span>
							<?php  } else { ?>
								<span class="label label-danger">未启用</span>
							<?php  } ?>
						</td>
						<td style="text-align:right;">
							<a href="<?php  echo $this->createWebUrl('postercate', array('op' => 'post', fid=>$row['fid'],'id' => $row['id'],'cattype'=>$cattype))?>" class="btn btn-default btn-sm" title="修改"><i class="fa fa-edit"></i></a>
							<a href="<?php  echo $this->createWebUrl('postercate', array('op' => 'delete', 'id' => $row['id']))?>"class="btn btn-default btn-sm" onclick="return confirm('此操作不可恢复，确认删除？');return false;" data-toggle="tooltip" data-placement="top" title="删除"><i class="fa fa-times"></i></a>
						</td>
					</tr>
					<?php  } } ?>
					
				<?php  } } ?>
				<tr>
					<td colspan="6">
						<input name="token" value="<?php  echo $_W['token'];?>" type="hidden">
						<input name="op" value="display" type="hidden">
						<input name="cattype" value="<?php  echo $cattype;?>" type="hidden">
						<input name="submit" class="btn btn-primary" value="修改排序" type="submit">
					</td>
				</tr>
			</tbody>
		</table>
		</form>
	</div>
</div>
<?php  } else if($operation == 'post') { ?>
<div class="main">
	<form action="" method="post" class="form-horizontal form" enctype="multipart/form-data">
		<input type="hidden" name="id" value="<?php  echo $othercat['id'];?>" />
		<input type="hidden" name="cattype" value="<?php  echo $cattype;?>" />
		<div class="panel panel-default">
			<div class="panel-heading">分类设置</div>
			<div class="panel-body">
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="displayorder" class="form-control" value="<?php  echo $othercat['displayorder'];?>" />
						<span class="help-block" style="color:red;">降序</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">分类名称</label>
					<div class="col-sm-9 col-xs-12">
						<input type="text" name="catename" class="form-control" value="<?php  echo $othercat['catename'];?>" />
					</div>
				</div>
				
				<?php  if($fid > 0 && $cattype == 1) { ?>
					<div class="form-group">
						<label class="col-xs-12 col-sm-3 col-md-2 control-label">上级分类</label>
						<div class="col-sm-9 col-xs-12">
							<select name="fid" class="form-control">
								<option value="请选择">选择上级分类</option>
								<?php  if(is_array($catlist)) { foreach($catlist as $cat) { ?>
								<option value="<?php  echo $cat['id'];?>" <?php  if($cat['id'] == $fid) { ?>selected="selected"<?php  } ?>><?php  echo $cat['catename'];?></option>
								<?php  } } ?>
							</select>
						</div>
					</div>
				<?php  } ?>
				
				
				<div class="form-group">
					<label class="col-xs-12 col-sm-3 col-md-2 control-label">是否启用</label>
					<div class="col-sm-9 col-xs-12">
						<label class="radio-inline"><input type="radio" name="enabled" value="1" <?php  if($othercat['enabled'] == 1) { ?>checked="true"<?php  } ?> /> 启用</label>
						&nbsp;&nbsp;&nbsp;
						<label class="radio-inline"><input type="radio" name="enabled" value="0" <?php  if($othercat['enabled'] == 0) { ?>checked="true"<?php  } ?> /> 不启用</label>					
					</div>
				</div>
			</div>
		</div>

		<div class="form-group col-sm-12">
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="token" value="<?php  echo $_W['token'];?>" />
		</div>
	</form>
</div>
<?php  } ?>
<?php (!empty($this) && $this instanceof WeModuleSite || 1) ? (include $this->template('common/footer', TEMPLATE_INCLUDEPATH)) : (include template('common/footer', TEMPLATE_INCLUDEPATH));?>